package admin

import (
	"go-cmdb/models"
)

type MonitorController struct {
	AdminController
}

func NewMonitorController() *MonitorController {
	ctrl := &MonitorController{}
	return ctrl
}

func (ctrl *MonitorController) Log() {

	ctrl.ViewData(map[string]interface{}{
		"title": "系统日志",
	})
	return

}
func (ctrl *MonitorController) LogPage() {

	var (
		pageSize, _  = ctrl.GetUint64("size", 0)
		pageIndex, _ = ctrl.GetUint64("page", 0)
		startTime    = ctrl.GetString("start_time", "")
		endTime      = ctrl.GetString("end_time", "")
	)

	lst, count, _ := models.NewLog().GetByPage(pageSize, pageIndex, startTime, endTime)

	ctrl.OK(map[string]interface{}{
		"rows":  lst,
		"total": count,
	})
	return

}
func (ctrl *MonitorController) FindLog() {

	var (
		id, _ = ctrl.GetUint64("id", 0)
	)
	m, _ := models.NewLog().Find(id)
	ctrl.OK(m)
	return

}
